package com.matriq.cloudmanager;

import com.matriq.cloudmanager.R;
import com.matriq.cloudmanager.entity.TeachPlan;

import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import net.lgpage.activity.BaseActivity;
import net.lgpage.util.Checker.StringUtils;

public class TeachPlanDetailActivity extends BaseActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ac_teach_plan_detail);
		setViews();
		setEvents();
		loadData();
	}

	TextView tv_content;
	//android.support.v4.widget.SwipeRefreshLayout srl;
	ScrollView sv;
	TextView tv_title;
	LinearLayout ll_content;
	ImageButton ll_back;
	LinearLayout ll_nothing;
	TextView tv_nothing;

	private void setViews() {
		tv_content = (TextView) this.findViewById(R.id.tv_content);
		//srl = (android.support.v4.widget.SwipeRefreshLayout) this.findViewById(R.id.srl);
		sv = (ScrollView) this.findViewById(R.id.sv);
		tv_title = (TextView) this.findViewById(R.id.tv_title);
		ll_content = (LinearLayout) this.findViewById(R.id.ll_content);
		ll_back = (ImageButton) this.findViewById(R.id.ll_back);
		ll_nothing = (LinearLayout) this.findViewById(R.id.ll_nothing);
		tv_nothing = (TextView) this.findViewById(R.id.tv_nothing);
	}

	private void setEvents() {
		ll_back.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
		});
		/*srl.setOnRefreshListener(new OnRefreshListener() {

			@Override
			public void onRefresh() {
				srl.setRefreshing(false);
			}
		});*/
	}

	TeachPlan obj;

	public void setData(TeachPlan obj) {
		this.obj = obj;
		tv_title.setText(obj.getTitle());
		tv_content.setText(Html.fromHtml(obj.getValue()));
		if(StringUtils.isEmpty(obj.getValue())){
			ll_nothing.setVisibility(View.VISIBLE);
			sv.setVisibility(View.GONE);
		}else{
			ll_nothing.setVisibility(View.GONE);
			sv.setVisibility(View.VISIBLE);
		}
	}

	private void loadData() {
		obj = (TeachPlan) intentGetObj(TeachPlan.class);
		setData(obj);
	}
	
	@Override
	public void onDestroy() {
		super.onDestroy();
	}

}